<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml">

	<ui:define name="body">

		<rich:panel>
			<f:facet name="header">Installed ProductLookupServices</f:facet>

			<div class="lookupServices"><h:outputText
				value="No ProductLookupService is installed!"
				rendered="#{empty lookupServices}" /> <h:dataTable
				id="lookupServiceList" var="service" value="#{lookupServices}"
				rendered="#{not empty lookupServices}">
				<h:column>
					<f:facet name="header">Name</f:facet>
                    #{service.name}
                </h:column>
				<h:column>
					<f:facet name="header">Url</f:facet>
					<h:outputLink value="#{service.url}">
						<h:outputText value="#{service.url}" />
					</h:outputLink>
				</h:column>
			</h:dataTable></div>
		</rich:panel>
		<h:form id="productSearchForm">

			<rich:panel>
				<f:facet name="header">Product</f:facet>

				<s:decorate id="eanNumberField" template="/layout/edit.xhtml">
					<ui:define name="label">EAN Number</ui:define>
					<h:inputText id="eanNumber" required="true"
						value="#{productSearch.eanNumber}" />
				</s:decorate>
    
				<script type="text/javascript">
				function updateEanNumberInput(barcode) {
					var ean = document.getElementById('productSearchForm:eanNumberField:eanNumber');
					ean.value = barcode;
				}
				</script>
				
				<ui:include src="/layout/scanner.xhtml">
				    <ui:param name="onDecodeSuccessCallback" value="updateEanNumberInput" />
				</ui:include>
				
				<div style="clear: both" />
			</rich:panel>

			<div class="actionButtons"><h:commandButton id="search"
				value="Search" action="#{productSearch.search}" /> <s:button
				id="cancel" propagation="none" value="Cancel"
				view="/view/productList.xhtml" /></div>

		</h:form>

	</ui:define>

</ui:composition>
